
{extend name="index/admin-index" /}
{block name="main"}
</style>
<link rel="stylesheet" href="/public/static/css/bootstrap.min.css">
  <!-- content start -->
  <div class="admin-content">
    <div class="admin-content-body">
      <div class="am-cf am-padding am-padding-bottom-0">
        <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">友情链接</strong> / <small>link management</small></div>
      </div>

      <hr/>

     
      <div class="am-g">
        <div class="am-u-sm-12 container" >

          <table class="am-table am-table-bd am-table-striped admin-content-table table-hover">
            <thead>
            <tr>
              <th><a href="{:url('admin/Links/ad')}" class='btn btn-primary' style='color:#fff;'>添加</a></th>
            </tr>
            <tr>
              <th  class="col-md-1">ID</th>
              <th class="col-md-3">链接名称</th>
              <th class="col-md-4">链接地址</th>
              <th class="col-md-2">状态</th><th>操作
            </tr>
            </thead>
            <tbody>
             {volist name="data" id="v"}
            <tr>
            <td>{$v.id}</td>
            <td>{$v.linkname}</td>
            <td style='overflow: hidden'>{$v.interlink}</td>
            <td id='stat'>
            <?php if ($v['status'] == 1): ?>
                <span class="btn btn-success" id='co' style="cursor: pointer;">
            <?php else: ?> 
                <span class="btn btn-danger"  style="cursor: pointer;">
            <?php endif; ?>
                    <!-- <a href="lst?a={$v.status}&id={$v.id}" style='color:#fff;'>{$v.status==1? '正常':'禁用'}</a> -->
                    <a href="javascript:void(0);" em='{$v.id}' style='color:#fff;'>{$v.status==1? '正常':'禁用'}</a>
                </span>
            </td>
              <td id='del'>
                <!-- <div class="am-dropdown" data-am-dropdown>
                  <button class="am-btn am-btn-default am-btn-xs am-dropdown-toggle" data-am-dropdown-toggle><span class="am-icon-cog"></span> <span class="am-icon-caret-down"> </span></button>

                  <ul class="am-dropdown-content"> -->

                    <a href="{:url('admin/Links/edi',['id'=>$v.id])}" class="btn btn-info " style='color:#fff;'> 编辑</a>
                    <!-- <a href="javascript:void(0);"   em='{$v.id}' class="btn btn-danger " style='color:#fff;'> 删除</a> -->
                    <span em='{$v.id}' class="btn btn-danger " style='color:#fff;'>删除</span>
          <!--         </ul>
                </div> -->
              </td>
            </tr>
            {/volist}
           
            </tbody>
          </table>
        </div>
      </div>

  

    </div>

<a href="#" class="am-icon-btn am-icon-th-list am-show-sm-only admin-menu" data-am-offcanvas="{target: '#admin-offcanvas'}"></a>
 
<footer>
  <hr>
  <p class="am-padding-left">© 2014 AllMobilize, Inc. Licensed under MIT license.</p>
</footer>
  </div>
  <script src='/public/static/js/jquery.js'></script>
<script>
    // 状态判断
    $('#stat a').click(function() {
        var s = $(this).html();
        var id = $(this).attr('em');
        var stat = '';
        if(s == '正常'){
          stat = 1;
          $(this).text("禁用");
          $(this).parent().attr('class','btn btn-danger');

        }else{
          stat = 0;
          $(this).text("正常");
         $(this).parent().attr('class','btn btn-success');
        }
          $.ajax({
            type:'get',
            url:'lst?a='+stat+'&id='+id+'',
          
            // dataType: 'json',
          })
    });

    // 删除数据
    $('#del span').click(function() {


      if(confirm('确定删除吗?')){
        $(this).parent().parent().remove();
          $.ajax({
            url:"{:url('admin/Links/del')}",
            type:'post',
            data:{
              'id':$(this).attr('em'),
            },
          });
      }
    });
    //编辑数据
    // $('#del a').click(function(){

    // })

 

</script>
{/block}